package com.wedo.mall.adapter;

import android.content.Context;
import android.widget.TextView;

import com.e.library.adapter.Adapter;
import com.e.library.adapter.EAdapter;
import com.wedo.mall.R;
import com.wedo.mall.entity.OrderMessage;
import com.wedo.mall.util.DateUtils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

/**
 * Created by Lawrence on 2017/8/15.
 */

public class OrderMessageAdapter extends Adapter<OrderMessage> {

    private SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");

    public OrderMessageAdapter(Context context, List<OrderMessage> orderMessages) {
        super(context, orderMessages);
    }

    @Override
    protected int layout() {
        return R.layout.item_ordermessage;
    }

    @Override
    protected void bind(EHolder holder, OrderMessage orderMessage, int position) {
        TextView tv_title = holder.find(R.id.tv_title);
        TextView tv_add_time = holder.find(R.id.tv_add_time);
        TextView tv_content = holder.find(R.id.tv_content);

        tv_title.setText(orderMessage.title);
        //tv_add_time.setText(format.format(new Date(Integer.parseInt(orderMessage.add_time))));
        tv_add_time.setText(DateUtils.convert(format,Long.parseLong(orderMessage.add_time)));
        tv_content.setText(orderMessage.content);

    }
}
